package com.es.www.deepCopy;

/**
 * @Created by michangtao
 * @Date 2022/5/12 16:58
 * @Description
 */
public class Operate {
    public static void main(String[] args) throws CloneNotSupportedException {
        Person person = new Person("mct", 23, new Phone("123"));
//        Person pClone1 = (Person) person.clone();
//        System.out.println(person == pClone1);
//        System.out.println(person.getPhone().hashCode() == pClone1.getPhone().hashCode());//false。说明成员变量新开辟了存储空间来存放复制的对象了

        Person pClone2 = (Person) person.deepClone();
        System.out.println(person.getPhone().hashCode() == pClone2.getPhone().hashCode());
    }
}
